package com.novatialabs.qttt.gwt.client;

import java.util.HashMap;
import java.util.Map;

public class Move {
  private final Notation notation = new BaseNotation();
  public final static Move BLANK_MOVE = new Move(0, 0, State.NOT_PLAYED);

  public enum State {
    NOT_PLAYED, ENTAGLED, COLLAPSED_TO_FIRST, COLLAPSED_TO_SECOND;

    public static Map<String, State> createSymbol2StateMap(String collapseFirst,
        String collapseSecond, String entagled, String notPlayed) {
      Map<String, State> map = new HashMap<String, State>();
      map.put(collapseFirst, COLLAPSED_TO_FIRST);
      map.put(collapseSecond, COLLAPSED_TO_SECOND);
      map.put(entagled, ENTAGLED);
      map.put(notPlayed, NOT_PLAYED);
      return map;
    }

    public static Map<State, String> createState2SymbolMap(String collaplseFirst,
        String collapseSecond, String entagled, String notPlayed) {
      Map<State, String> map = new HashMap<State, String>();
      map.put(COLLAPSED_TO_FIRST, collaplseFirst);
      map.put(COLLAPSED_TO_SECOND, collapseSecond);
      map.put(ENTAGLED, entagled);
      map.put(NOT_PLAYED, notPlayed);
      return map;
    }
  }

  private final int firstMark;
  private final int secondMark;
  private final State state;

  public Move(int firstMark, int secondMark, State state) {
    this.firstMark = firstMark;
    this.secondMark = secondMark;
    this.state = state;
  }

  public int getFirstMark() {
    return firstMark;
  }

  public int getSecondMark() {
    return secondMark;
  }

  public State getState() {
    return state;
  }

  @Override
  public String toString() {
    return notation.printMove(this);
  }

}
